package com.shen.JUC.pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

//Executors 工具类、三大方法
public class Pool1 {
    public static void main(String[] args) {
        ExecutorService service = Executors.newSingleThreadExecutor();//单个线程
        Executors.newFixedThreadPool(5);//创建一个固定线程池
        Executors.newCachedThreadPool();//可伸缩的线程池

        try {
            for (int i = 0; i < 10; i++) {
                service.execute(()->{
                    System.out.println(Thread.currentThread().getName()+" thread");
                });
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            service.shutdown();
        }
    }

}
